package com.codeoss.module.stock.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codeoss.framework.service.impl.BaseService;
import com.codeoss.module.stock.dao.StockOutConfirmLineMapper;
import com.codeoss.module.stock.model.StockOutConfirm;
import com.codeoss.module.stock.model.StockOutConfirmLine;
import com.codeoss.module.stock.model.StockOutLine;
import com.codeoss.module.stock.service.IStockOutConfirmLineService;

@Service
public class StockOutConfirmLineService extends BaseService<StockOutConfirmLineMapper, StockOutConfirmLine>
		implements IStockOutConfirmLineService {
	@Override
	@Transactional
	public StockOutConfirmLine createConfirmLine(StockOutConfirm stockOutConfirm, StockOutLine stockOutLine) {
		// TODO Auto-generated method stub
		StockOutConfirmLine stockOutConfirmLine=new StockOutConfirmLine();
		stockOutConfirmLine.setStockOutConfirmId(stockOutConfirm.getId());
		stockOutConfirmLine.setStockOutLineId(stockOutLine.getId());
		stockOutConfirmLine.setTargetQty(stockOutLine.getQtyEntered());
		stockOutConfirmLine.setConfirmedQty(stockOutLine.getQtyEntered());
		stockOutConfirmLine.setScrappedQty(new BigDecimal(0));
		stockOutConfirmLine.setProductProductId(stockOutLine.getProductProductId());
		stockOutConfirmLine.setProductAttrSetInstanceId(stockOutLine.getProductAttrSetInstanceId());
		stockOutConfirmLine.setUomUomId(stockOutLine.getUomUomId());
		insert(stockOutConfirmLine);
		return stockOutConfirmLine;
	}

	@Override
	public List<StockOutConfirmLine> getLineListByStockOutConfirmId(Long stockOutConfirmId) {
		// TODO Auto-generated method stub
		QueryWrapper<StockOutConfirmLine> query=new QueryWrapper<StockOutConfirmLine>();
		query.eq("stock_out_confirm_id", stockOutConfirmId);
		return list(query);
	}
}